/// <license>
/// Copyright (c) 2002-2008, DotNetNuke Corporation
/// All rights reserved
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
/// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
/// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
/// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
/// of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
/// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
/// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
/// DEALINGS IN THE SOFTWARE.
/// </license>

#region Using Statements

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;

using DotNetNuke.Common.Utilities;

using DotNetNuke.ModuleToolkit.Modules.Data;

#endregion

namespace DotNetNuke.ModuleToolkit.Modules.Skinning.Skins
{
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// Business Layer class for Skins
    /// </summary>
    /// <history>
    ///     [cnurse]  10/11/2007  Created
    /// </history>
    /// -----------------------------------------------------------------------------
    public static class SkinController
    {

        #region Public Static Methods

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds a Skin to the DataStore
        /// </summary>
        /// <param name="section">The Skin to persist</param>
        /// <returns>An integer that represents the Id of the new Skin</returns>
        /// <history>
        /// 	[cnurse]	10/12/2007	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static int AddSkin(SkinInfo skin)
        {
            return DataService.CreateSkin(skin.PackageId, skin.DesktopModuleId, skin.Name);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Deletes a Skin from the DataStore
        /// </summary>
        /// <param name="section">The Skin to delete</param>
        /// <history>
        /// 	[cnurse]	10/13/2007	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void DeleteSkin(SkinInfo skin)
        {
            DataService.DeleteSkin(skin.SkinId);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets Skin from the Data Store
        /// </summary>
        /// <param name="skinId">The id of the skin</param>
        /// <returns>A SkinInfo object</returns>
        /// <history>
        ///     [cnurse]  10/13/2007  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static SkinInfo GetSkin(int skinId)
        {
            return CBO.FillObject<SkinInfo>(DataService.GetSkin(skinId));
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets Skin from the Data Store
        /// </summary>
        /// <param name="desktopModuleId">The id of the module</param>
        /// <param name="skinName">The name of the Skin</param>
        /// <returns>A SkinInfo object</returns>
        /// <history>
        ///     [cnurse]  10/11/2007  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static SkinInfo GetSkinByName(int desktopModuleId, string skinName)
        {
            return CBO.FillObject<SkinInfo>(DataService.GetSkinByName(desktopModuleId, skinName));
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a Skin from the Data Store by its Package Id
        /// </summary>
        /// <param name="packageId">The id of the package</param>
        /// <returns>A SkinInfo object</returns>
        /// <history>
        ///     [cnurse]  10/13/2007  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static SkinInfo GetSkinByPackageID(int packageId)
        {
            return CBO.FillObject<SkinInfo>(DataService.GetSkinByPackageID(packageId));
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the skins for a module from the Data Store
        /// </summary>
        /// <param name="desktopModuleId">The id of the module</param>
        /// <returns>A List of SkinInfo objects</returns>
        /// <history>
        ///     [cnurse]  10/11/2007  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static List<SkinInfo> GetSkins(int desktopModuleId)
        {
            return CBO.FillCollection<SkinInfo>(DataService.GetSkins(desktopModuleId));
        }

        #endregion

    }
}
